package com.zyit.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zyit.dto.HospitalDto;
import com.zyit.pojo.Hospital;
import com.zyit.vo.HospitalVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface HospitalMapper extends BaseMapper<Hospital> {
    @Select("<script>" +
            "select h.*,hs.*,p.provinceName,c.cityName,a.areaName " +
            " from hospital h,hospital_set hs,province p,city c,area a" +
            " where h.hoscode=hs.hoscode" +
            " and h.province_code=p.provinceCode" +
            " and h.city_code=c.cityCode" +
            " and h.district_code=a.areaCode" +
            "<if test=\"hosname!=null and hosname!=''\"> and h.hosname like \"%\"#{hosname}\"%\"</if>" +
            "<if test=\"hoscode!=null and hoscode!=''\"> and h.hoscode=#{hoscode}</if>" +
            " limit #{page},#{limit}" +
            "</script>")
    List<HospitalVo> findAll(HospitalDto hospitalDto);

    @Select("<script>" +
            "select count(1) " +
            " from hospital h <where>" +
            "<if test=\"hosname!=null and hosname!=''\"> and h.hosname like \"%\"#{hosname}\"%\"</if>" +
            "<if test=\"hoscode!=null and hoscode!=''\"> and h.hoscode=#{hoscode}</if>" +
            "</where></script>")
    int getCount(HospitalDto hospitalDto);
}
